package com.spsoft.vatoutinv.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.spsoft.core.annotation.AnonymousAccess;
import com.spsoft.core.annotation.Log;
import com.spsoft.core.controller.BaseController;
import com.spsoft.core.enums.LogActionType;
import com.spsoft.core.enums.LogMenuEnum;
import com.spsoft.core.model.Result;
import com.spsoft.core.model.bo.TokenUser;
import com.spsoft.vatoutinv.model.dto.vmsenterpriseinforisk.VmsEnterpriseInfoRiskDto;
import com.spsoft.vatoutinv.model.dto.vmsenterpriseinforisk.VmsEnterpriseInfoRiskLogDto;
import com.spsoft.vatoutinv.model.vo.vmsenterpriseinforisk.VmsEnterpriseInfoRiskLogVo;
import com.spsoft.vatoutinv.model.vo.vmsenterpriseinforisk.VmsEnterpriseInfoRiskVo;
import com.spsoft.vatoutinv.service.vmsenterpriseinfo.VmsEnterpriseInfoService;
import com.spsoft.vatoutinv.service.vmsenterpriseinforisk.VmsEnterpriseInfoRiskLogService;
import com.spsoft.vatoutinv.service.vmsenterpriseinforisk.VmsEnterpriseInfoRiskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 纳税人风险信息管理 前端控制器
 * </p>
 *
 * @author chenxudong
 * @since 2023-11-22
 */
@RestController
@Api(tags = {"纳税人风险信息管理"})
@RequestMapping("/vmsEnterpriseInfoRisk")
@RequiredArgsConstructor
@Validated
@Slf4j
public class VmsEnterpriseInfoRiskController extends BaseController {

    public static final String RISK_MSG = "(纳税人风险信息控制层)";

    public static final String RISK_LOG_MSG = "(纳税人风险信息获取记录控制层)";

    private final VmsEnterpriseInfoService vmsEnterpriseInfoService;

    private final VmsEnterpriseInfoRiskService vmsEnterpriseInfoRiskService;

    private final VmsEnterpriseInfoRiskLogService vmsEnterpriseInfoRiskLogService;

    @ApiOperation("查询纳税人风险信息")
    @AnonymousAccess(value = "/queryVmsEnterpriseInfoRisk", method = RequestMethod.POST, permissionCode = "VMS_DISKINFO")
    @Log(value = "纳税人风险信息接口", type = LogActionType.SELECT, menuName = LogMenuEnum.TAXPAYERS_RISK_INFO)
    public Result<VmsEnterpriseInfoRiskVo> queryVmsEnterpriseInfoRisk() {
        VmsEnterpriseInfoRiskDto vmsEnterpriseInfoRiskDto = new VmsEnterpriseInfoRiskDto();
        vmsEnterpriseInfoRiskDto.setDeptCode(getDeptCode());
        log.info("{}查询纳税人风险信息入参：{}", RISK_MSG, JSONObject.toJSONString(vmsEnterpriseInfoRiskDto));
        return vmsEnterpriseInfoRiskService.queryVmsEnterpriseInfoRisk(vmsEnterpriseInfoRiskDto);
    }

    @ApiOperation("调用乐企获取纳税人风险信息")
    @AnonymousAccess(value = "/getVmsEnterpriseInfoRiskByLq", method = RequestMethod.POST, permissionCode = "VMS_ENTERPRISE_RISK_ADD")
    @Log(value = "调用乐企获取纳税人风险信息", type = LogActionType.ADD, menuName = LogMenuEnum.TAXPAYERS_RISK_INFO)
    public Result<Object> getVmsEnterpriseInfoRiskByLq() {
        VmsEnterpriseInfoRiskDto vmsEnterpriseInfoRiskDto = new VmsEnterpriseInfoRiskDto();
        vmsEnterpriseInfoRiskDto.setNsrsbh(vmsEnterpriseInfoService.getNsrsbh());
        TokenUser userInfo = getUser();
        log.info("{}调用乐企获取纳税人风险信息入参：{}", RISK_MSG, JSONObject.toJSONString(vmsEnterpriseInfoRiskDto));
        return vmsEnterpriseInfoRiskService.getVmsEnterpriseInfoRiskByLq(vmsEnterpriseInfoRiskDto, userInfo);
    }

    @ApiOperation("查询纳税人风险信息获取记录")
    @AnonymousAccess(value = "/queryVmsEnterpriseInfoRiskLog", method = RequestMethod.POST, permissionCode = "VMS_DISKINFO")
    @Log(value = "查询纳税人风险信息获取记录接口", type = LogActionType.SELECT, menuName = LogMenuEnum.TAXPAYERS_RISK_INFO)
    public Result<IPage<VmsEnterpriseInfoRiskLogVo>> queryVmsEnterpriseInfoRisk(@RequestBody VmsEnterpriseInfoRiskLogDto vmsEnterpriseInfoRiskLogDto) {
        vmsEnterpriseInfoRiskLogDto.setDeptCode(getDeptCode());
        log.info("{}纳税人风险信息获取记录入参：{}", RISK_LOG_MSG, JSONObject.toJSONString(vmsEnterpriseInfoRiskLogDto));
        return vmsEnterpriseInfoRiskLogService.queryVmsEnterpriseInfoRiskLog(vmsEnterpriseInfoRiskLogDto);
    }

}

